﻿using UnityEngine;
using System.Collections;
using System.Xml;
using GameDevClicker.Data;

/// <summary>
/// Base gatherer, adjusting resources every tick.
/// </summary>
public abstract class ResourceGatherer {
    public int Amount { get; private set; }
    public int Level { get; private set; }

    public string Name { get { return GetName(); } }
    public string Description { get { return GetDescription(); } }

    protected Resource resource { get; set; }

    private int gather { get; set; }
    private int modifier { get; set; }

    public ResourceGatherer(int amount = 0, int level = 0) {
        Amount = amount;
        Level = level;
    }

    /// <summary>
    /// Calculate and increase the resource based on the GatherPerTick.
    /// </summary>
    /// <param name="useModifier">Use the modifier or not.</param>
    public void Tick(bool useModifier = true) {
        int amount = Amount * gather;
        if (useModifier) {
            if (useModifier) {
                float baseVal = (float)(amount) / 100f;
                float addition = baseVal * modifier;
                amount += (int)(addition);
            }
        }

        resource.Add(amount);
    }

    /// <summary>
    /// Returns the name of the current level.
    /// </summary>
    protected abstract string GetName();

    /// <summary>
    /// Returns the description of the current level.
    /// </summary>
    protected abstract string GetDescription();
}